<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <TITLE>ThinkPHP示例：附件上传</TITLE>
<link rel='stylesheet' type='text/css' href='__PUBLIC__/Css/common.css'>
 </HEAD>
 <BODY>
 <div class="main">
 <H2>ThinkPHP示例之：附件上传</H2>
 本示例演示了如何使用内置的文件上传类库进行附件上传操作，使用了Ajax方式上传。
 <div id="main" class="main" >
<SCRIPT LANGUAGE="JavaScript">
<!--
function addRow(){   
	curFileNum++;
	rowsnum++;
    var row=tbl.insertRow(-1);
	//var td = arow.insertCell();
	var cell = document.createElement("td");
	cell.innerHTML='<div class="fLeft hMargin"><IMG SRC="__PUBLIC__/Images/del.gif"  style="cursor:hand" onfocus="javascript:getObject(this)" onclick="deleteRow();" WIDTH="20" HEIGHT="20" BORDER="0" ALT="删除" align="absmiddle"></div> <div class="impBtn  fLeft" ><INPUT TYPE="file" id="file'+curFileNum+'" name="file'+ curFileNum +'" class="file  huge"></div><div class="fLeft hMargin"></div>';
	cell.align="center"
	row.appendChild(cell); 
	//addFileForm.num.value=rowsnum;
}
function deleteRow(){
	if(tbl.rows.length>0){
		tbl.deleteRow(rindex); //删除当前行
		rowsnum--;    
	}else{
		return;
	}
	rindex="";
}
function getObject(obj){ 
	rindex=obj.parentElement.parentElement.rowIndex;/*当前行对象*/
}

function uploading(msg){
	document.getElementById('result').style.display = 'block';
	document.getElementById('result').innerHTML	=	'<IMG SRC="__PUBLIC__/Images/ajaxloading.gif" WIDTH="16" HEIGHT="16" BORDER="0" ALT="" align="absmiddle"> 文件上传中～';
	return true;
}

function uploadComplete(){

}
//-->
</SCRIPT>
<div class="content">
<form id="upload" METHOD=POST action="__URL__/upload/" enctype="multipart/form-data" target="iframeUpload">
<TABLE cellpadding=3 cellspacing=3 width="450PX">
<TR>
	<TD colspan="2" class="tLeft">
	<div class="result" style="background:#E9E9F3">上传允许文件类型：rar zip txt和doc文件，单个文件大小不超过105k，允许同时上传多个文件。</div>
	<INPUT TYPE="button" value="增 加" onclick="addRow();" class="button small"> <INPUT TYPE="submit" value="上 传" onclick="uploading();" class="small button "></TD>
</TR>
<TR>
	<TD class="tRight tTop"></TD>
	<TD class="tLeft tTop">
	<div id="result" class="result none"></div>
	<INPUT TYPE="hidden" name="ajax" value="1">
	<iframe name="iframeUpload" src="" width="350" height="35" frameborder=0  SCROLLING="no" style="display:NONE"></iframe>
	<input type="hidden" name="MAX_FILE_SIZE" value="106836" />
	<INPUT TYPE="hidden" name="_uploadFileResult" value="result">
	<INPUT TYPE="hidden" name="_uploadFormId" value="upload">
	<INPUT TYPE="hidden" name="_uploadFileSize" value="106836">
	<INPUT TYPE="hidden" NAME="_uploadFileType" value="rar,doc,zip,txt" >
	<INPUT TYPE="hidden" name="_uploadResponse" value="uploadComplete">
	<INPUT TYPE="hidden" name="_uploadSavePath" value="<?php echo APP_PATH.'/../'.'Public/Uploads/';?>" >
	<TABLE id='tbl' style="clear:both"></TABLE>
</TD>
</TR>

<TR>
<TD class="tRight tTop"></TD>
	<TD  class="tLeft"><HR> 示例源码<BR>控制器IndexAction类<BR><php>highlight_file(LIB_PATH.'Action/IndexAction.class.php');</php></TD>
</TR>
</TABLE>
</form>
</div>
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
var curFileNum = 0;
var rowsnum=0;  //记录行数
var rindex="";       //列索引
var tbl	=	document.getElementById('tbl');
addRow();
//-->
</SCRIPT>
</div>
 </BODY>
</HTML>
